/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.sbbs.admin.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.sbbs.base.jpa.entity.BaseAuditTreeEntity;

/**
 *
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "sys_org",
        indexes = {
            @Index(name = "idx_pid_fk", columnList = "pid")}
)

@Comment("系统部门表")
public class SysOrg extends BaseAuditTreeEntity {

    private static final long serialVersionUID = -3526403255769199010L;

    @Comment("状态")
    @Column(name = "state")
    private boolean state;
    
    @Comment("正式性:正式下面可以是临时的,临时下可以是临时的,临时下不可是正式的")
    @Column(name = "is_formal")
    private boolean formal;
    
//    @Comment("组织类型:单位/部门,单位/部门下可有部门,部门下不可有单位")
//    @Column(name = "type")
//    private Integer type;
//    
    //    @Transient
    @Formula("(select count(1)>0 from sys_org t where t.pid=id)")
    private boolean hasChildren;
    @Transient
    private boolean leaf=false;

}
